package com.vgulu.server.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created by Administrator on 2014/7/11 0011.
 */
public class ResponseUtil {
    private static Logger logger = LoggerFactory.getLogger(ResponseUtil.class);
    public static void writeJsonToResponse(String value,HttpServletResponse response){
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        try {
            OutputStream out = response.getOutputStream();
            logger.debug(value);
            out.write(value.getBytes("UTF-8"));
            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
